// 定义类
class Point{
    x:number;
    y:number;
    constructor(x:number, y:number){
        this.x=x;
        this.y=y;
    }
}


// 获取类的类类型
// 方式1
function createPoint( 
    PointClass:typeof Point,// 类的类型
    x:number,
    y:number){
    return new PointClass(x,y)
}

// 方式2
interface PointConstructor {
    new(x:number, y:number) : Point;
}
function createPoint2(PointClass:PointConstructor, x:number, y:number){
    return new PointClass(x,y)
}


// 类简写
 class Point2{
    constructor(public x:number, public y:number){
        console.log('已经创建实例：x:'+this.x+', y:'+ this.y)
    }
 }

 const p2 = new Point2(23,45);
 console.log(p2)


 // 泛型类写法
class Box<T>{
    name:T;
    constructor(name:T){
        this.name =name;
    }
}
const box1 =new Box<string>('翠花');
console.log(box1)

// 抽象类
abstract class A{
    id=1
}
class SuperA extends A{
    id=12
}  


// 带this 的函数
function add(this:any, x:number){
    console.log('this',this)
}

add.call({x:12, y:15},100);



